{$extend "/master" $}


{$define "#content" |
	content = $.profile_email ? "#profile" : "#loading_content"
}
	{$partial content $}
{$}


{$define "#profile" |
	shirt = $.pick_shirt ? "#shirt" |
	game = $.pick_game ? "#game" |
	shipping = $.pick_shipping ? "#shipping"
}
<div id="content">

<h1>Backer Profile</h1>

<h2>Personal</h2>
<p>
	Pledge Amount: <strong>${$insert~h $.profile_pledge_amount $} USD</strong>
</p>
<p>
	Reward Level: <strong>{$insert~h $.profile_reward_level $}</strong>
</p>
<p>
	Email: <input id="profile_email" type="text" value="{$insert~h $.profile_email $}" readonly> <input id="modify_email" type="button" value="modify">
</p>
<p>
	Name: <input id="profile_name" type="text" value="{$insert~h $.profile_name $}">
</p>
<p>
	Twitter: @<input id="profile_twitter" type="text" value="{$insert~h $.profile_twitter $}"> <small>(optional)</small>
</p>
<p>
	Phone: <input id="profile_phone" type="text" value="{$insert~h $.profile_phone $}"> <small>(optional)</small>
</p>
<p>
	"Thank You's" Listing: <input id="profile_credit" type="text" value="{$insert~h $.profile_credit $}">
</p>

{$partial shirt $}

{$partial shipping $}

{$partial game $}

<p>
	<input id="update_profile" type="button" value="update">
</p>

{$partial "#email_modal" $}

</div>
{$}


{$define "#shirt" |
	shirt_sizes["S","M","L","XL","2XL","3XL","4XL","5XL"] = $.profile_shirt_size ? "selected" |
	empty_shirt_size = !$.profile_shirt_size ? "selected"
}
<p>
	Shirt Size:
	<select id="profile_shirt_size">
		<option value="" {$insert empty_shirt_size $}>--</option>
	{$loop shirt_sizes }
		<option value="{$insert _.key $}" {$insert _.value $}>{$insert _.key $}</option>
	{$}
	</select> <small>(adult unisex sizes)</small>
{$}


{$define "#game" }
<h2>Game</h2>
<small>options coming soon</small>
{$}


{$define "#shipping" |
	shipping_type = $.profile_shipping.domestic ? "#domestic_shipping" : "#international_shipping"
}
<h2>Shipping</h2>
<small>please list a permanent address, good for at least the next 3-6 months</small>

{$partial shipping_type $}

{$}


{$define "#domestic_shipping" }
<div id="shipping_info">
<p>
	<input id="profile_shipping_domestic" type="checkbox" checked> Domestic (USA) Address
</p>
<p>
	Address:<br>
	<textarea id="profile_shipping_address" cols="50" rows="3">{$insert~h $.profile_shipping.address $}</textarea>
</p>
<p>
	<input id="profile_shipping_city" type="text" value="{$insert~h $.profile_shipping.city $}" placeholder="-- City --" title="-- City --">
	{$partial "#state" $}
	<input id="profile_shipping_zip" type="text" value="{$insert~h $.profile_shipping.zip $}" placeholder="-- ZIP --" title="-- ZIP --">
</p>
</div>
{$}


{$define "#state" |
	empty_choice = !$.profile_shipping.state ? "selected" |
	state_choice["AL","AK","AZ","AR","CA","CO","CT","DC","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"] = $.profile_shipping.state ? "selected"
}
<select id="profile_shipping_state">
	<option value="" {$insert empty_choice $}>--state--</option>
	{$loop state_choice }
	<option value="{$insert _.key $}" {$insert _.value $}>{$insert _.key $}</option>
	{$}
</select>
{$}


{$define "#international_shipping" }
<div id="shipping_info">
<p>
	<input id="profile_shipping_domestic" type="checkbox"> Domestic (USA) Address
</p>
<p>
	Full Address (including country):<br>
	<textarea id="profile_shipping_address" cols="50" rows="5">{$insert~h $.profile_shipping.address $}</textarea>
</p>
</div>
{$}


{$define "#email_modal" }
<div id="email_modal">
<h2>Modify Email</h2>
<p>
	Old Email: <input id="old_email" type="text" value="{$insert~h $.profile_email $}" readonly>
</p>
<p>
	New Email: <input id="new_email" type="text">
</p>
<p>
	<input id="update_email" type="button" value="modify">
	&nbsp;&nbsp;&nbsp;
	<input id="cancel_update" type="button" value="cancel">
</p>
</div>
{$}
